﻿using System.Collections.Generic;
using System.Linq;
using Less.SRV;
using Less.Core;
using Less.Core.Model;

namespace LessBoard.Models
{
    public class LogModel
    {
        private static readonly LogSRV SRV = new LogSRV("auditConnection");

        // TODO: Create Count methods at DAL

        public long NumMetricMessages
        {
            get { return SRV.GetBySeverity(EntrySeverities.Metric).Count; }
        }

        public long NumWarningMessages
        {
            get { return SRV.GetBySeverity(EntrySeverities.Warning).Count; }
        }

        public long NumErrorMessages
        {
            get { return SRV.GetByMinSeverity(EntrySeverities.Error).Count; }
        }


        public IEnumerable<LogEntry> LogErrorEntries
        {
            get { return SRV.GetByMinSeverity(EntrySeverities.Error).Take(5); }
        }

        public IEnumerable<LogEntry> LogMetricEntries
        {
            get
            {
                return SRV.GetBySeverity(EntrySeverities.Metric).Take(5);
            }
        }

        
    }
    public class SeveritiesModel
    {
        public IEnumerable<LogEntriesBySeveritySummary> LogEntriesBySeveritySummary { get; set; }
    }

    public  class EntriesOfSeverityModel
    {
        public  EntrySeverities SeverityOfEntries { get; set; }
        public  IEnumerable<LogEntry> LogEntriesOfSeverity { get; set; }
    }
}